local tafeng = fk.CreateSkill {
  name = "3s__tafeng",
}

Fk:loadTranslationTable{
  ["3s__tafeng"] = "踏锋",
  [":3s__tafeng"] = "你每回合首次使用牌后，你可摸两张牌。若如此做，本回合内：所有角色手牌中，目标为角色且不为伤害类的基本牌和锦囊牌均视为【杀】；你使用或其他角色对你使用这些【杀】无距离次数限制。",

  ["$3s__tafeng1"] = "踏锋破浪，锐不可当！",
  ["$3s__tafeng2"] = "锋刃所至，所向披靡！",
}

-- 记录每回合首次使用牌
tafeng:addEffect(fk.CardUseFinished, {
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(tafeng.name) then return end
    -- 使用事件记录器查询本回合是否已使用过牌
    return #player.room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
      return e.data.from == player end, Player.HistoryTurn) == 1
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, tafeng.name)
    for _, p in ipairs(player.room:getAlivePlayers()) do
      player.room:addPlayerMark(p, "3s__tafeng-turn")
    end
  end,
})

tafeng:addEffect("filter", {
  card_filter = function(self, card, player)
    return player:getMark("3s__tafeng-turn") > 0 and card and not card.is_passive and not card.is_damage_card and
    card.type ~= Card.TypeEquip and table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, player, card)
    local c = Fk:cloneCard("slash", card.suit, card.number)
    c.skillName = tafeng.name
    return c
  end,
})

tafeng:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card, to)
    if not to then return end
    return card and player:getMark("3s__tafeng-turn") > 0 and card.name == "slash"
    and (player:hasSkill(tafeng.name) or to:hasSkill(tafeng.name))
    and table.contains(card.skillNames, tafeng.name)
  end,
  bypass_distances = function(self, player, skill, card, to)
    if not to then return end
    return card and player:getMark("3s__tafeng-turn") > 0 and card.name == "slash"
    and (player:hasSkill(tafeng.name) or to:hasSkill(tafeng.name))
    and table.contains(card.skillNames, tafeng.name)
  end,
})

return tafeng